#include "../lv_examples.h"
#if LV_BUILD_EXAMPLES && LV_USE_BTN

lv_obj_t * btn1;
lv_obj_t * btn2;
lv_obj_t * label1;
lv_obj_t * label2;

static void btn_event_cb1(lv_event_t * e)
{
    lv_event_code_t code = lv_event_get_code(e);
    lv_obj_t * btn = lv_event_get_target(e);
    if(code == LV_EVENT_CLICKED)
    {
        static uint8_t cnt = 0;
        cnt++;

        /*Get the first child of the button which is the label and change its text*/
        lv_obj_t * label = lv_obj_get_child(btn, lv_obj_get_index(btn));
        lv_label_set_text_fmt(label, "Button1: %d", cnt);
    }
}

static void btn_event_cb2(lv_event_t * e)
{
	static uint8_t cnt = 0;
    lv_event_code_t code = lv_event_get_code(e);
    lv_obj_t * btn = lv_event_get_target(e);
    if(code == LV_EVENT_CLICKED)
    {
        cnt++;

        /*Get the first child of the button which is the label and change its text*/
        lv_obj_t * label = lv_obj_get_child(btn, lv_obj_get_index(btn));
        lv_label_set_text_fmt(label, "Button2: %d", cnt);
    }
}

void lv_example_get_started_1(void)
{
//    btn1 = lv_btn_create(lv_scr_act());     /*Add a button the current screen*/
//    lv_obj_set_pos(btn1, 10, 10);                            /*Set its position*/
//    lv_obj_set_size(btn1, 120, 50);                          /*Set its size*/
//    lv_obj_add_event_cb(btn1, btn_event_cb1, LV_EVENT_ALL, NULL);           /*Assign a callback to the button*/

//    label1 = lv_label_create(btn1);          /*Add a label to the button*/
//    lv_label_set_text(label1, "Button1");                     /*Set the labels text*/
//    lv_obj_center(label1);

    btn2 = lv_btn_create(lv_scr_act());     /*Add a button the current screen*/
    lv_obj_set_pos(btn2, 150, 10);                            /*Set its position*/
    lv_obj_set_size(btn2, 120, 50);                          /*Set its size*/
    lv_obj_add_event_cb(btn2, btn_event_cb2, LV_EVENT_ALL, NULL);           /*Assign a callback to the button*/

    label2 = lv_label_create(btn2);          /*Add a label to the button*/
    lv_label_set_text(label2, "Button2");                     /*Set the labels text*/
    lv_obj_center(label2);
}

#endif

